package ca.uwaterloo.call;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class ContactRegister extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.contact);
		
		final TextView name = (TextView) findViewById(R.id.editText2);
		final TextView phone = (TextView) findViewById(R.id.editText1);
		final TextView alert =  (TextView) findViewById(R.id.editText3);
		final Button go = (Button) findViewById(R.id.button1);
		
		go.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				String N = name.getText().toString();
				String P = phone.getText().toString();
				String A = alert.getText().toString();
				if (N.length()>0 && P.length()>0) {
					Intent CallBack = new Intent();
					CallBack.putExtra("New_Name", N);
					CallBack.putExtra("New_Phone", P);
					if (A.length()>0) { CallBack.putExtra("New_Alert",A);}
					else {CallBack.putExtra("New_Alert", "0");}
					setResult(RESULT_OK,CallBack);
					finish();
					
				}
			}
			
		});
	}
	
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_main, menu);
		return true;
	}
}
